package com.kaifamiao.io.d0921;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

public class FileOutputStreamDemo {

    public static void main(String[] args) {
        String path = "d:\\io\\file-output-gbk.txt";
        try (FileOutputStream fos = new FileOutputStream(path);){

            fos.write(97);
            fos.write('b');
            fos.write('\r');
            fos.write('\n');

            fos.write('c');

            String str = "开发喵";

            byte[] bytes = str.getBytes(Charset.forName("gbk"));

            fos.write(bytes);

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
